Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AudioManager = undefined;
var $2ConstValue = require("ConstValue");
var $2GameUser = require("GameUser");
var $2Platformconf = require("Platformconf");
var $2UIHelp = require("UIHelp");
var $2Globe = require("Globe");
var exp_AudioManager = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.bgm = "";
    this._playing = false;
    this._playedlist = {};
  }
  return babel_createClass(_ctor, [{
    key: "playSound",
    value: function playSound(e, t, n, _l, c) {
      var _this = this;
      if ($2Platformconf.default.PlatformType == $2Platformconf.ePlatformType.VIVOGame) {
        if (!$2GameUser.default.getInstance().audio) {
          return void (c && $2UIHelp.UIHelp.showTip("请在设置中打开音效！"));
        }
      } else if (!$2GameUser.default.getInstance().audio && null == c) {
        return void (_l && _l(-1));
      }
      if (!$2GameUser.default.getInstance().audio && (null == c || $2Platformconf.default.PlatformType == $2Platformconf.ePlatformType.VIVOGame)) {
        return void (_l && _l(-1));
      }
      var d = $2ConstValue.ConstValue.AUDIO_DIR + e;
      -1 != e.indexOf("/") && (d = e);
      $2Globe.default.getInstance().bundleLoad(d, function (e, o) {
        if (e) {
          return void (_l && _l(-1));
        }
        if ($2Platformconf.default.PlatformType == $2Platformconf.ePlatformType.OPPOGame) {
          console.log("oppo", _this._playedlist);
          if (1 != _this._playedlist[d]) {
            _this._playedlist[d] = 1, cc.audioEngine.play(o, false, .1);
          }
        }
        var i = cc.audioEngine.play(o, t || false, n || 1);
        _l && _l(i);
      });
    }
  }, {
    key: "stopAll",
    value: function stopAll() {
      cc.audioEngine.stopAll();
    }
  }, {
    key: "getState",
    value: function getState(e) {
      return cc.audioEngine.getState(e);
    }
  }, {
    key: "stop",
    value: function stop(e) {
      cc.audioEngine.stop(e);
    }
  }, {
    key: "resumeAll",
    value: function resumeAll() {
      $2GameUser.default.getInstance().bgm && cc.audioEngine.resumeMusic();
    }
  }, {
    key: "pauseAll",
    value: function pauseAll() {
      cc.audioEngine.pauseAll();
    }
  }, {
    key: "pauseMusic",
    value: function pauseMusic() {
      cc.audioEngine.pauseMusic();
    }
  }, {
    key: "stopMusic",
    value: function stopMusic() {
      cc.audioEngine.stopMusic();
    }
  }, {
    key: "resumeMusic",
    value: function resumeMusic() {
      this.playBGM(this.bgm);
    }
  }, {
    key: "playBGM",
    value: function playBGM(e) {
      var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Audio/";
      if (this.bgm == e && cc.audioEngine.isMusicPlaying()) {
        return;
      }
      this.bgm = e;
      if (!$2GameUser.default.getInstance().bgm) {
        return;
      }
      cc.audioEngine.stopMusic();
      var n = t + e;
      $2Globe.default.getInstance().bundleLoad(n, function (e, t) {
        if (e) {
          cc.error(e);
        } else if ($2GameUser.default.getInstance().bgm) {
          cc.audioEngine.playMusic(t, true), cc.audioEngine.setMusicVolume(.8);
        }
      });
    }
  }], [{
    key: "getInstance",
    value: function getInstance() {
      null == this.instance && (this.instance = new _ctor());
      return this.instance;
    }
  }]);
}();
exports.AudioManager = exp_AudioManager;
exp_AudioManager.instance = null;